define(['app'], function(app) {
    'use strict';

    //实例化方法
    var factory = function (Http) {
        //显示商品价格
		function get_data_afupdate(result){
			if(false){
				result = '{"success":true,"msg":"","result":{"order":[{"order_id":1,"order_time":"2017-3-15 15:50:20","goods":[{"goods_id":1,"goods_name":"电动钢丝锯","image":"img/auction/14_4.jpg","price":998},{"goods_id":2,"goods_name":"电动钢丝锯","image":"img/auction/14_4.jpg","price":998},{"goods_id":3,"goods_name":"电动钢丝锯","image":"img/auction/14_4.jpg","price":998}]}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			}else
			return result;
		}
		//修改价格
		function get_afupdate(result){
            if(false){
                result = '{"success":true,"msg":"","result":{"order":[{"order_id":1,"order_time":"2017-3-15 15:50:20","goods":[{"goods_id":1,"goods_name":"电动钢丝锯","image":"img/auction/14_4.jpg","price":998},{"goods_id":2,"goods_name":"电动钢丝锯","image":"img/auction/14_4.jpg","price":998},{"goods_id":3,"goods_name":"电动钢丝锯","image":"img/auction/14_4.jpg","price":998}]}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
                return JSON.parse(result);
            }else
            return result;
        }

        //返回信息
        return {
            af_update:function(order_id,callback){
            	Http.post({
            		method:'order.changeprice.detail',
            		order_id:order_id,
            		picSize:'CS'
            	},function(result){
            		if(callback)
            		callback(get_data_afupdate(result).result);
            	},function(e){

            	},function(){

            	})
            },
            af_change:function(order_id,cost_freight,callback){
            	Http.post({
            		method:'trades.order.costfreight.update',
            		order_id:order_id,
            		cost_freight:cost_freight,
            	},function(result){
            	    console.log(result)
                    if(callback)
                    callback(get_afupdate(result));

            	},function(e){

            	},function(){

            	})
            }

        };
    }

    factory.$inject = ['Http'];
    return app.registerService("Afupdate", factory);
});